home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / Compiler / nodes.h < prev    next >
C/C++ Source or Header  |  1990-08-16  |  8KB  |  331 lines

  1. /*
  2.  * @(#)nodes.h    1.9  1/20/89
  3.  */
  4. #ifndef nodes_h
  5. #define nodes_h
  6.  
  7. #ifndef ident_h
  8. #include "ident.h"
  9. #endif
  10. #ifndef symbols_h
  11. #include "symbols.h"
  12. #endif
  13. #ifndef tags_h
  14. #include "tags.h"
  15. #endif
  16. #ifndef tokens_h
  17. #include "tokens.h"
  18. #endif
  19. #ifndef types_h
  20. #include "types.h"
  21. #endif
  22. #ifndef set_h
  23. #include "set.h"
  24. #endif
  25.  
  26. #define LASTZEROLOCALS        P_SETQ
  27. #define LASTONELOCAL        P_OPSIG
  28. #define LASTTWOLOCALS        P_INVOC
  29.  
  30. typedef struct sObjectFlags {
  31.       Boolean         immutable        :1;
  32.       Boolean         isManifest        :1;
  33.       Boolean         writeSeparately    :1;
  34.       Boolean         cannotBeConformedTo    :1;
  35.       Boolean         isVector        :1;
  36.       Boolean         isTypeVariable        :1;
  37.       Boolean         resultsDependOnlyOnArgs:1;
  38.       Boolean         inExecutableConstruct    :1;
  39.       Boolean         dependsOnTypeVariable    :1;
  40.       Boolean         typesAreAssigned    :1;
  41.       Boolean         typesHaveBeenChecked    :1;
  42.       Boolean         doesNotDuplicateSelf    :1;
  43.       Boolean         doesNotMoveArguments    :1;
  44.       Boolean         doLocalCreate        :1;
  45.       Boolean         typeDependsOnTypeVariable:1;
  46.       Boolean         doesNotMoveSelf    :1;
  47.       unsigned         unused            :16;
  48. } ObjectFlags;
  49.  
  50. #define BIGNUMBER 20
  51. typedef struct sNode {
  52.   Tag             tag        :8;
  53.   unsigned int         firstChild    :8;
  54.   short             lineNumber;
  55.   short             nChildren, maxChildren;
  56.   union {
  57.     /* Three local variables */
  58.     struct {
  59.       ObjectFlags     f;
  60.       OID         codeOID;
  61.       OID         id;
  62.       struct sNode *name, *fields;
  63.     }                        recordlit,
  64.                         unionlit;
  65.     struct {
  66.       ObjectFlags     f;
  67.       OID         codeOID;
  68.       OID         id;
  69.       struct sNode *syms;
  70.     }                        enumlit;
  71.     struct {
  72.       ObjectFlags     f;
  73.       OID         unused1;
  74.       OID         unused2;
  75.       struct sNode *type, *exp, *vectorType;
  76.     }                        vectorlit;
  77.     struct {
  78.       Boolean         isDone            :1;
  79.       Boolean         isOK            :1;
  80.       Boolean         marked            :1;
  81.       Boolean         onStack        :1;
  82.       Boolean         isTypeVariable        :1;
  83.       Boolean         dependsOnTypeVariable    :1;
  84.       Boolean         isImport        :1;
  85.       Boolean         unused            :17;
  86.       Tag         tag            :8;
  87.       unsigned         number            :16;
  88.       unsigned         lowLink        :16;
  89.       struct sNode    *dependsOn;
  90.       struct sNode    *answer;
  91.       struct sNode    *definingThing;
  92.     } knowct;
  93.     struct {
  94.       Boolean         isDone            :1;
  95.       Boolean         isOK            :1;
  96.       Boolean         marked            :1;
  97.       Boolean         onStack        :1;
  98.       Boolean         isTypeVariable        :1;
  99.       Boolean         dependsOnTypeVariable    :1;
  100.       Boolean         isImport        :1;
  101.       Boolean         unused            :17;
  102.       Tag         tag            :8;
  103.       unsigned         number            :16;
  104.       unsigned         lowLink        :16;
  105.       Set         dependsOn;
  106.       struct sNode    *answer;
  107.       struct sNode    *definingThing;
  108.     } knowlocal, knowmanifest;
  109.     struct {
  110.       ObjectFlags     f;
  111.       OID         codeOID;
  112.       OID         id;
  113.       struct sNode    *sfname, *setq, *name, *ops;
  114.     }                        atlit;
  115.     struct {
  116.       ObjectFlags     f;
  117.       unsigned         codeOID;
  118.       OID         id;
  119.       struct sNode    *sfname, *setq, *name, *myat, *instat, *export,
  120.             *decls, *monitor, *ops, *process;
  121.     }                        oblit;
  122.     /* Two local variables */
  123.     struct {
  124.       OID id;
  125.       struct sNode    *value;
  126.     }                        globalref;
  127.     struct {    /* since in doSymbols we change a selflit to a symref. */
  128.       int         unused1, unused2;
  129.     }                        selflit;
  130.     struct {
  131.       Ident         ident;
  132.       short int         unused;
  133.       Symbol         symbol;
  134.     }                        symref,
  135.                         symdef;
  136.     struct { 
  137.       Ident         ident;
  138.       short int         unused;
  139.       OID id;
  140.     }                        opname;
  141.     struct {
  142.       Boolean         isInlineable        :1;
  143.       Boolean         isExported        :1;
  144.       Boolean         isUniversal        :1;
  145.       Boolean         isMonitored        :1;
  146.       Boolean         isPrivate        :1;
  147.       unsigned int     unused            :27;
  148.       int         opNumber;
  149.       struct sNode    *sig, *body;
  150.     }                        opdef;
  151.     struct {
  152.       short int         opNumber;
  153.       Boolean         isLocal        :1;
  154.       Boolean         unused            :15;
  155.       OID         resultTypeOID;
  156.       struct sNode *target, *opname, *args;
  157.     }                        invoc;
  158.     /* One local variable */
  159.     struct {
  160.       Ident         ident;
  161.       short int         unused;
  162.     }                         ident;
  163.     struct { char *string; }             string,
  164.                         charlit,
  165.                             intlit,
  166.                         reallit,
  167.                         stringlit;
  168.     struct { Boolean value; }            boollit;
  169.     struct { int whichType; }            builtinlit;
  170.     struct {
  171.       Boolean         mayBeElided        :1;
  172.       unsigned int     unused            :31;
  173.       struct sNode *decls, *ops, *init, *recovery;
  174.     }                        monitor;
  175.     struct {
  176.       Boolean         move:1;
  177.       Boolean         visit:1;
  178.       Boolean         isAttached:1;
  179.       unsigned         unused:29;
  180.       struct sNode    *sym, *type, *constraint;
  181.     }                        param;
  182.     struct {
  183.       Boolean         move:1;
  184.       Boolean         visit:1;
  185.       unsigned         unused:30;
  186.       struct sNode    *exp;
  187.     }                        arg;
  188.     struct { Ident ident; }            fieldref;
  189.     struct {
  190.       Boolean         needsNoInvokeQueue:1;
  191.       unsigned         unused:31;
  192.       struct sNode *stats, *unavailablehandler, *failurehandler;
  193.     }                        block;
  194.     struct {
  195.       Boolean         useSignalAndExit:1;
  196.       unsigned         unused:31;
  197.       struct sNode *exp;
  198.     }                        signalstat;
  199.     struct {
  200.       Boolean          confirm:1;
  201.       unsigned         unused:31;
  202.       Token         verb;
  203.       struct sNode    *loc;
  204.     }                        checkpointstat;
  205.     struct {
  206.       Boolean         isAttached        :1;
  207.       unsigned int     unused            :31;
  208.       struct sNode *sym, *type, *value;
  209.     }                        constdecl,
  210.                         vardecl;
  211.     struct {
  212.       Boolean         isRedundant:1;
  213.       Boolean         unused:31;
  214.       struct sNode *exp, *type;
  215.     }                        view;
  216.     struct {
  217.       int         whichResult;
  218.     }                        nthresult;
  219.     struct {
  220.       Boolean          isFunction        :1;
  221.       Boolean         mustBeCompilerExecuted    :1;
  222.       unsigned int     unused            :30;
  223.       struct sNode    *name, *params, *results, *where;
  224.     }                        opsig;
  225.     /* No locals */
  226.     struct {
  227.       struct sNode *import, *export, *consts;
  228.     }                        comp;
  229.     struct {
  230.       struct sNode *syms, *path;
  231.     }                        import,
  232.                         export;
  233.     struct {
  234.       Token        implementation;
  235.       struct sNode *ctype;
  236.     }                        pragma;
  237.     struct {
  238.       struct sNode *body;
  239.     }                        processdef,
  240.                         initdef,
  241.                         recoverydef,
  242.                         failurehandler;
  243.     struct {
  244.       struct sNode *decl, *body;
  245.     }                        unavailablehandler;
  246.     struct {
  247.       struct sNode *ifclauses, *elseclause;
  248.     }                        ifstat;
  249.     struct {
  250.       struct sNode *exp, *stats;
  251.     }                        ifclause;
  252.     struct {
  253.       struct sNode *stats;
  254.     }                        elseclause,
  255.                         loopstat;
  256.     struct {
  257.       struct sNode *exp;
  258.     }                        exitstat,
  259.                         assertstat,
  260.                         unfixstat,
  261.                         waitstat;
  262.     struct {
  263.       struct sNode *left;
  264.       Token op;
  265.       struct sNode *right;
  266.     }                        assignstat,
  267.                         exp;
  268.     struct {
  269.       struct sNode *exp, *loc;
  270.     }                        fixstat,
  271.                         refixstat,
  272.                         movestat;
  273.     /* return statement */
  274.     /* returnAndFail statement */
  275.     struct {
  276.       struct sNode *target, *fieldref;
  277.     }                        fieldsel;
  278.     struct {
  279.       struct sNode *target, *exp;
  280.     }                        subscript;
  281.     struct {
  282.       struct sNode *target, *opname, *args;
  283.     }                        selection;
  284.     struct {
  285.       struct sNode *sym;
  286.       Token        op;
  287.       struct sNode *type;
  288.     }                        wherewidgit;
  289.     struct {
  290.       struct sNode *number, *vars, *vals;
  291.     }                        primstat;
  292.     struct {
  293.       Token        op;
  294.       struct sNode *exp;
  295.     }                        unaryexp;
  296.     struct {
  297.       struct sNode *exp, *type;
  298.     }                        restrict;
  299.     struct {
  300.       struct sNode *inner, *param, *outer;
  301.     }                        setq;
  302.     struct sNode    *children[BIGNUMBER];
  303.   } b;
  304. } Node, *NodePtr;
  305.  
  306. NodePtr F_NewNode();
  307.  
  308. extern char *tagNames[];
  309.  
  310. #define NewNode(T) F_NewNode(T, 0)
  311.  
  312. extern void Sequence_Free();
  313.  
  314. #define FreeNode(N) \
  315.   if ((int) (N) <= 0x200) ; \
  316.   else { \
  317.     if ((N)->nChildren > 0) Sequence_Free(N); \
  318.     free((char *)(N)); \
  319.   }
  320. #define BODYSIZE 8
  321. #define NodeSize(N) (BODYSIZE + ((N)->maxChildren) * sizeof(NodePtr))
  322. #define UsedNodeSize(N) (BODYSIZE + ((N)->nChildren) * sizeof(NodePtr))
  323. #define NN ((NodePtr) NULL)
  324. #define ISTOKEN(n) ((int)(n) <= 0x200)
  325. #define ChildIndex(p, child) ((NodePtr)&(child) - &(p)->b.children[0])
  326. #define setCodeOID(p, id) (p)->b.oblit.codeOID = (id)
  327. #define getCodeOID(p) ((OID) (p)->b.oblit.codeOID)
  328. #define GETVALUE(p) ((p) == NN ? (p) : (p)->tag == P_GLOBALREF ? getValue(p) : (p))
  329. extern NodePtr getValue();
  330. #endif
  331.